<template>
  <base-breadcrumb>
    <searchData
      :search-data="searchArr"
      @search="search"
    />
    <a-card :bordered="false">
      <!-- <title-name title="印章管理与回收" /> -->
      <list-table
        ref="table"
        :columns="columns"
        :request="loadData"
        :export-config="{ use: true,select: '项目印章管理回收',all: '项目印章管理回收'}"
        :export-permission="{select:'oa_010_exp_02',all:'oa_010_exp_02'}"
      >
        <template
          slot="prefix"
        >
          <a-button
            v-btn-permission="'oa_010_add_01'"
            type="primary"
            icon="plus"
            @click="$nav('add')"
          >
            新增印章
          </a-button>
        </template>
        <span slot="index" slot-scope="text, record, index">{{ index + 1 }}</span>
        <template
          slot="auditStatusStr"
          slot-scope="text, record"
        >
          <list-status
            :status="record.auditStatus"
            :text="text"
          />
        </template>
        <template
          slot="recycleStatus"
          slot-scope="text"
        >
          <span
            v-if="text==='未回收'"
            style="color:red;"
          >{{ text }}</span>
          <span
            v-else-if="text==='分公司已回收'"
            style="color:#FF7E00;"
          >{{ text }}</span>
          <span
            v-else-if="text==='使用中'"
            style="color:#008000;"
          >{{ text }}</span>
          <span v-else>{{ text }}</span>
        </template>
        <template
          slot="operation"
          slot-scope="text, record"
        >
          <MoreButton>
            <a @click="$nav('add',{id:record.id,detail:1})">查看</a>
            <a
              v-btn-permission="'oa_010_add_01'"
              @click="$nav('add',{id:record.id})"
            >编辑</a>
            <!--                                                <span @click="handleDel(record.id)">删除</span>-->
            <template v-if="record.recycleStatus == '未回收' || record.recycleStatus == '使用中'">
              <a
                v-btn-permission="'oa_010_bre_03'"
                @click="rowId = record.id;visible = true"
              >分公司回收</a>
            </template>
            <!--                                                <span @click="rowId = record.id;visible = true">分公司回收</span>-->
            <template v-if="record.recycleStatus == '分公司已回收'">
              <a
                v-btn-permission="'oa_010_cre_04'"
                @click="rowId = record.id;visible = true"
              >公司回收</a>
            </template>
          </MoreButton>
        </template>
      </list-table>
    </a-card>
    <recycleSeal
      :row-id="rowId"
      :visible.sync="visible"
      @ok="search()"
    />
  </base-breadcrumb>
</template>

<script>
import projectApi from '@/api/office/seal/project'
import ExportMould from '@/components/ExportMould'
import SelectCompanyAndProject from '@/components/Select/SelectCompanyAndProject'
import recycleSeal from '@/views/office/sealManagement/project/recycleSeal'
import SelectPerson from '@/components/Select/SelectPerson'
import OrgTreeSelect from '@/components/OrgTreeSelect'

export default {
    name: 'ProjectIndex',
    components: {
        recycleSeal,
    },
    data() {
        return {
            rowId: '',
            columns: [
                {
                    title: '序号',
                    dataIndex: 'index',
                    width: 70,
                    scopedSlots: { customRender: 'index' }
                },
                {
                    title: '单位名称',
                    dataIndex: 'depName',
                    width: 220
                },
                {
                    title: '印章名称',
                    dataIndex: 'sealName',
                    width: 220
                },
                {
                    title: '竣工时间',
                    dataIndex: 'completionTime',
                    width: 120
                },
                {
                    title: '项目状态',
                    dataIndex: 'projectTime',
                    width: 100
                },
                {
                    title: '保管部门',
                    dataIndex: 'departmentName',
                    width: 120
                },
                {
                    title: '保管人',
                    dataIndex: 'preserverName',
                    width: 100
                },
                {
                    title: '联系电话',
                    dataIndex: 'preserverPhone',
                    width: 120
                },
                {
                    title: '印章状态',
                    dataIndex: 'sealStatus',
                    width: 100
                },
                {
                    title: '回收状态',
                    dataIndex: 'recycleStatus',
                    scopedSlots: { customRender: 'recycleStatus' },
                    width: 100
                },
                {
                    title: '回收时间',
                    dataIndex: 'recycleTime',
                    width: 150
                },
                {
                    title: '操作',
                    width: 250,
                    fixed: 'right',
                    scopedSlots: { customRender: 'operation' }
                }
            ],
            searchArr: [
                // 搜索框
                {
                  name: '单位',
                  valueKey: 'searchQuery',
                  type: OrgTreeSelect,
                },
                // {
                //     name: '单位',
                //     type: SelectCompanyAndProject,
                //     valueKey: 'depId'
                // },
                {
                    name: '印章名称',
                    value: 'sealName',
                    type: 'input',
                },
                {
                    name: '回收状态',
                    value: 'recycleStatus',
                    type: 'select',
                    data: [
                        { label: '未回收', value: '未回收' },
                        { label: '已回收', value: '已回收' },
                        { label: '分公司已回收', value: '分公司已回收' },
                        { label: '使用中', value: '使用中' }
                    ]
                }
            ],
            loadData: (params) => {
                return projectApi.getPage(Object.assign(params, { query: this.queryParam }))
            },
            queryParam: {},
            visible: false,
            visible2: false
        }
    },
    created() {
    },
    methods: {
        search(val) {
            this.queryParam = val || {}
            this.$refs.table.getData(null, true)
        },
        handleDel(id) {
            this.$delList3(projectApi.delete, () => {
                this.search()
            }, { id })
        }
    }
}
</script>
